// stores/counter.js
import { defineStore } from "pinia";
import { localGet } from "../../utils";

export const useUsersStore = defineStore("users", {
  state: () => {
    return {
      username: localGet("username") || null,
      nickname: localGet("nickname") || null,
    };
  },
  // 也可以定义为
  // state: () => ({ count: 0 })
  getters: {
    getUsers: (state) => (state.username = localGet("username")),
  },
  actions: {
    saveUsers(payload) {
      // console.log(payload);
      this.username = payload;
    },
    saveNickName(payload) {
      this.nickname = payload;
    },
  },
});
